<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;
use App\Model\AdminModel;
use App\Model\PermissionModel;

class Admin extends Seeder
{
	/**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
//		$salt = random(16, 3, '0123456789abcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+<>,.');
//		$password = genPsw('123456', $salt);
//		AdminModel::create([
//			'username' => 'admin',
//			'password' => $password,
//			'salt' => $salt,
//			'last_login_ip' => '127.0.0.1',
//			'last_login_at' => date('Y-m-d H:i:s', time()),
//			'created_at' => date('Y-m-d H:i:s', time()),
//			'updated_at' => date('Y-m-d H:i:s', time()),
//		]);

		$permissions = [
			[
				'id' => 1,
				'type' => 0,
				'pid' => 0,
				'authority' => 'common',
				'name' => '常规管理',
				'request_uri' => null,
				'request_method' => null,
				'menu_icon' => 'fa fa-address-book',
				'sort' => 1,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 2,
				'type' => 0,
				'pid' => 1,
				'authority' => 'system',
				'name' => '系统管理',
				'request_uri' => null,
				'request_method' => null,
				'menu_icon' => 'fa fa-gears',
				'sort' => 2,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 3,
				'type' => 1,
				'pid' => 2,
				'authority' => 'permission:index',
				'name' => '权限管理',
				'request_uri' => '/admin/permissions',
				'request_method' => 'GET',
				'menu_icon' => 'fa fa-gears',
				'sort' => 3,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 4,
				'type' => 3,
				'pid' => 3,
				'authority' => 'permission:menus',
				'name' => '菜单树',
				'request_uri' => '/admin/menus',
				'request_method' => 'GET',
				'menu_icon' => null,
				'sort' => 4,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 5,
				'type' => 2,
				'pid' => 3,
				'authority' => 'permission:create',
				'name' => '权限创建',
				'request_uri' => '/admin/permission/create',
				'request_method' => null,
				'menu_icon' => null,
				'sort' => 5,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 6,
				'type' => 3,
				'pid' => 3,
				'authority' => 'permission:store',
				'name' => '权限保存',
				'request_uri' => '/admin/permission/store',
				'request_method' => 'POST',
				'menu_icon' => null,
				'sort' => 6,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 7,
				'type' => 2,
				'pid' => 3,
				'authority' => 'permission:edit',
				'name' => '权限编辑',
				'request_uri' => '/admin/permission/edit/{id}',
				'request_method' => 'GET',
				'menu_icon' => null,
				'sort' => 7,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 8,
				'type' => 3,
				'pid' => 3,
				'authority' => 'permission:update',
				'name' => '权限更新',
				'request_uri' => '/admin/permission/{id}',
				'request_method' => 'PUT',
				'menu_icon' => null,
				'sort' => 8,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 9,
				'type' => 3,
				'pid' => 3,
				'authority' => 'permission:info',
				'name' => '权限信息',
				'request_uri' => '/admin/permission/{id}',
				'request_method' => 'GET',
				'menu_icon' => null,
				'sort' => 9,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
			[
				'id' => 10,
				'type' => 3,
				'pid' => 3,
				'authority' => 'permission:del',
				'name' => '权限删除',
				'request_uri' => '/admin/permission/{id}',
				'request_method' => 'DELETE',
				'menu_icon' => null,
				'sort' => 10,
				'deleted_at' => null,
				'created_at' => date('Y-m-d H:i:s', time()),
				'updated_at' => date('Y-m-d H:i:s', time()),
			],
		];
		foreach ($permissions as $permission) {
			PermissionModel::create($permission);
		}
	}
}
